import React, { Component } from 'react';
import { connect } from 'dva';
import { Modal } from 'antd-mobile';
import NameCard from '../../components/name-card';
import OrderStatus from '../../components/order-status';
import router from 'umi/router';
import styles from './index.less';
import { fetchApi } from '@/utils/utils';

@connect(({ my }) => ({ my }))
class MyIndex extends Component {
  constructor(props) {
    super(props);
    this.state = {
      nowdata: 0,
      name: '登录/注册',
      avatar: '',
      phone: localStorage.getItem('phone'),
      not_login: localStorage.getItem('phone') ? true : false,
    };
  }
  componentDidMount() {
    const { dispatch } = this.props;
  }
  linkurl(v) {
    if (v === 'address') {
      router.push('/collection');
    } else {
      router.push('/history');
    }
  }
  render() {
    const { my } = this.props;
    const { not_login, phone } = this.state;
    return (
      <div className={styles.content_me}>
        <NameCard
          name={phone ? phone : '登陆/注册'}
          avatar={this.state.avatar}
          notLogin={not_login ? 1 : 0}
        />
        <div className={styles.service_info + ' ' + 'box_shadow'}>
          <div className={styles.service_title + ' ' + 'border_bottommin'}>个人信息</div>
          <div className={styles.service_content}>
            <div className={styles.service_item} onClick={() => this.linkurl('account')}>
              <img className={styles.service_img} src={require('../../assets/lishi.png')} alt="" />
              <div className={styles.service_text}>历史记录</div>
            </div>
            <div className={styles.service_item} onClick={() => this.linkurl('address')}>
              <img className={styles.service_img} src={require('../../assets/icon-.png')} alt="" />
              <div className={styles.service_text}>收藏列表</div>
            </div>
            <div
              className={styles.service_item}
              onClick={() => {
                console.log('帮助中心');
              }}
            >
              <img
                className={styles.service_img}
                src={require('../../assets/gerenzhongxin.png')}
                alt=""
              />
              <div className={styles.service_text}>个人中心</div>
            </div>
          </div>
        </div>
      </div>
    );
  }
}
export default MyIndex;
